<?php

class McCube_Template_Parser_Element_Command_Loop
    extends McCube_Template_Parser_Element_Command_Abstract{

    public function execution(array $element){
        $iter = $element['name'].'Iterator';
        $val  = $element['name'];
        foreach($this->_tplEngine->loops[$element['name']] as $$iter=>$$val){

        }
    }

    public function buildStart(array $element){

        $model = new McCube_Template_Parser_Inline($this->_tplEngine,array(
            'variable' => array(
                  $element['name']            => current($this->_tplEngine->loops[$element['name']])
                , $element['name'].'Iterator' => key    ($this->_tplEngine->loops[$element['name']])
            )
        ));
        $string = $model->parse($element['content']);

        $this->execution($element);

        return parent::buildPhpTag('foreach('
            .'$this->_loops[\''.$element['name'].'\'] '
            .'as $'.$element['name'].'Iterator=>$'.$element['name']
        .'):')
        .$string
        .parent::buildPhpTag('endforeach;');
    }
}